#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
用户自定义类的操作符重载测试
"""

from gtest import test, EXPECT_TRUE, EXPECT_FALSE


class Point:
    """简单的点类，用于测试操作符重载"""

    def __init__(self, x: int, y: int):
        self.x: int = x
        self.y: int = y

    def __eq__(self, other: "Point") -> bool:
        """点相等比较"""
        x_eq: bool = self.x == other.x
        y_eq: bool = self.y == other.y
        return x_eq and y_eq

    def get_x(self) -> int:
        """获取 x 坐标"""
        return self.x

    def get_y(self) -> int:
        """获取 y 坐标"""
        return self.y


@test("CustomClassOperators", "EqualityOperator")
def test_custom_equality() -> None:
    """测试自定义类的 == 操作符"""
    p1: Point = Point(1, 2)
    p2: Point = Point(1, 2)
    p3: Point = Point(3, 4)

    result1: bool = p1 == p2
    result2: bool = p1 == p3

    EXPECT_TRUE(result1)
    EXPECT_FALSE(result2)
